<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>资产信息管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function() {
            //$("#name").focus();
            $("#inputForm").validate({
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });

        });
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="${ctx}/inventory/hostInventory/">主机列表</a></li>
    <li class="active"><a href="${ctx}/inventory/hostInventory/detailedForm?id=${hostInventory.id}">主机信息录入</a></li>
</ul><br/>
<form:form id="inputForm" modelAttribute="hostInventory" action="${ctx}/inventory/hostInventory/detailedSave" method="post" class="form-horizontal">
    <form:hidden path="id"/>
    <sys:message content="${message}"/>
    <fieldset>
        <legend>主机基本信息 </legend>
        <table>
            <tr>
                <td>
                    <div class="control-group">
                        <label class="control-label">主机是否监控：</label>
                        <div class="controls">
                            ${fns:getDictLabel(hostInventory.inventoryMode, "yes_no", "未知")}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">分类：</label>
                        <div class="controls">
                            ${fns:getDictLabel(hostInventory.type, "host_inventory_type", "未知")}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">分类详情：</label>
                        <div class="controls">
                            ${hostInventory.typeFull}
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="control-group">
                        <label class="control-label">主机名（监控标识）：</label>
                        <div class="controls">
                            ${hostInventory.name}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">别名：</label>
                        <div class="controls">
                            ${hostInventory.alias}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">资产标签：</label>
                        <div class="controls">
                            ${hostInventory.assetTag}
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="control-group">
                        <label class="control-label">硬件：</label>
                        <div class="controls">
                            ${hostInventory.hardware}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">硬件详情：</label>
                        <div class="controls">
                            ${hostInventory.hardwareFull}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">联系信息：</label>
                        <div class="controls">
                            ${hostInventory.contact}
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="control-group">
                        <label class="control-label">软件：</label>
                        <div class="controls">
                            ${hostInventory.software}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">软件详情：</label>
                        <div class="controls">
                            ${hostInventory.softwareFull}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">服务编码：</label>
                        <div class="controls">
                            ${hostInventory.notes}
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="control-group">
                        <label class="control-label">型号：</label>
                        <div class="controls">
                            ${hostInventory.model}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">供应商：</label>
                        <div class="controls">
                            ${hostInventory.vendor}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">合同：</label>
                        <div class="controls">
                            ${hostInventory.contractNumber}
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="control-group">
                        <label class="control-label">IP(外网)：</label>
                        <div class="controls">
                            ${hostInventory.tag}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">IP(内网)：</label>
                        <div class="controls">
                            ${hostInventory.siteRack}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">端口信息：</label>
                        <div class="controls">
                            ${hostInventory.siteNotes}
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="control-group">
                        <label class="control-label">购买日期：</label>
                        <div class="controls">
                            ${hostInventory.dateHwPurchase}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">上架日期：</label>
                        <div class="controls">
                            ${hostInventory.dateHwInstall}
                        </div>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label class="control-label">质保日期：</label>
                        <div class="controls">
                            ${hostInventory.dateHwExpiry}
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <div style="text-align:right"><a class="btn btn-primary" href="${ctx}/inventory/hostInventory/form?id=${hostInventory.id}">修改</a></div>
                </td>
            </tr>
        </table>
    </fieldset>
        <fieldset>
            <legend>位置信息（机架内从上往下）</legend>
            <table>
                <tr>
                    <td>
                        <div class="control-group"><label>机架：</label>
                            <form:select path="cabinetId" class="input-medium">
                                <form:option value="" label=""/>
                                <form:options items="${availableCabinets}" itemLabel="label" itemValue="id" htmlEscape="false"/>
                            </form:select>
                            <%--<sys:treeselect id="cabinet" name="cabinetId" value="${hostInventory.cabinetId}" labelName="hostInventory.cabinetCode" labelValue="${hostInventory.cabinetCode}"
                                            title="机架" url="/inventory/zlmtCabinet/treeData?type=1" cssClass="" allowClear="true" notAllowSelectParent="false"/>--%>
                        </div>
                    </td>

                    <td >
                        <div class="control-group"><label>从第</label>
                            <form:input path="unitUsedCode" htmlEscape="false" size="5"  class="input-mini"/>
                            U开始占用
                            <form:select path="unitUsed" class="input-mini">
                                <form:option value="2" label="2"/>
                                <form:option value="1" label="1"/>
                                <form:option value="6" label="6"/>
                            </form:select>U&nbsp;&nbsp;
                        </div>
                    </td>
                    <td>
                        <div style="text-align: right" class="control-group"><label>柜内序号：</label>
                            <form:input path="hostLocCode" htmlEscape="false" size="5" class="input-mini"/>

                        <c:if test="${empty choosedCabinet}">
                                <input id="btnSubmit" class="btn btn-primary" type="submit" value="上架"/>&nbsp;
                        </c:if>
                        <c:if test="${not empty choosedCabinet}">
                                <input id="btnSubmit" class="btn btn-primary" type="submit" value="更新"/>&nbsp;
                        </c:if>

                        </div>
                    </td>
                </tr>
                <tr>

                </tr>
                <c:if test="${not empty choosedCabinet}">
                    <tr>
                        <td>
                            <div class="control-group"><label>当前位置：</label>
                                ${choosedCabinet.label}，从上往下第${choosedLoc.unitUsedCode}格开始占用${choosedLoc.unitUsed}U&nbsp;&nbsp;&nbsp;
                            </div>
                        </td>
                        <td>
                            <div class="control-group"><label>柜内序号：</label>
                                ${choosedLoc.hostLocCode}
                            </div>
                        </td>
                        <td>
                            <div class="control-group"><label>上架时间：</label>
                                <fmt:formatDate value="${choosedLoc.fromTime}" pattern="yyyy-MM-dd"/>
                            </div>
                        </td>
                    </tr>
                </c:if>
            </table>
        </fieldset>
</form:form>
        <fieldset>
            <legend>配件信息</legend>
            <form:form id="inputFormAccessory" modelAttribute="zlmtHostsAccessory" action="${ctx}/inventory/hostInventory/addAccessory" method="post" class="form-horizontal">
                <form:hidden path="hostid"/>
            <table>
                <tr>
                    <td>
                        <div class="control-group"><label>类别：</label>
                            <form:select path="accessoryCategory" class="input-small">
                                <form:options items="${fns:getDictList('accessory_cate')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                            </form:select>
                        </div>
                    </td>
                    <td>
                        <div class="control-group"><label>配件名：</label>
                            <form:input path="accessoryName" htmlEscape="false"  class="input-small"/>
                        </div>
                    </td>
                    <td>
                        <div class="control-group"><label>型号：</label>
                            <form:input path="model" htmlEscape="false"  class="input-small"/>
                        </div>
                    </td>

                    <td>
                        <div class="control-group"><label>品牌：</label>
                            <form:input path="brand" htmlEscape="false"  class="input-small"/>
                        </div>
                    </td>

                    <td>
                        <div class="control-group"><label>数量：</label>
                            <form:input path="amount" htmlEscape="false"  class="input-small"/>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="control-group"><label>联系信息：</label>
                            <form:input path="contact" htmlEscape="false"  class="input-small"/>
                        </div>
                    </td>

                    <td>
                        <div class="control-group"><label>上架时间：</label>
                            <form:input path="inuseDate"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"   class="input-small Wdate"  />
                        </div>
                    </td>
                    <td>
                        <div class="control-group"><label>质保时间：</label>
                            <form:input path="warrantyDate"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"   class="input-small Wdate"  />
                        </div>
                    </td>
                    <td  align="right">
                        <input id="btnSubmitAccessory" class="btn btn-primary" type="submit" value="添加"/>
                    </td>
                </tr>
            </table>
            </form:form>
            <table  id="contentTable1" class="table table-striped table-bordered table-condensed">
                <thead>
                    <th>类别</th>
                    <th>配件名</th>
                    <th>型号</th>
                    <th>品牌</th>
                    <th>数量</th>
                    <th>联系信息</th>
                    <th>上架时间</th>
                    <th>质保时间</th>
                    <th>操作</th>
                </thead>
                <tbody>
                <c:forEach items="${accessoryList}" var="accessory">
                    <tr>
                        <td>${fns:getDictLabel(accessory.accessoryCategory, "accessory_cate", "未知")}</td>
                        <td>${accessory.accessoryName}</td>
                        <td>${accessory.model}</td>
                        <td>${accessory.brand}</td>
                        <td>${accessory.amount}</td>
                        <td>${accessory.contact}</td>
                        <td><fmt:formatDate value="${accessory.inuseDate}" pattern="yyyy-MM-dd"/></td>
                        <td><fmt:formatDate value="${accessory.warrantyDate}" pattern="yyyy-MM-dd"/></td>
                        <td>
                            <a href="${ctx}/duty/zlmtMaintenanceRecord/form?hostid=${accessory.hostid}&accessoryId=${accessory.id}" >维修记录</a>&nbsp;&nbsp;
                            <a href="${ctx}/inventory/hostInventory/deleteAccessory?hostid=${accessory.hostid}&id=${accessory.id}" onclick="return confirmx('确认要删除该配件吗？', this.href)">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </fieldset>
<fieldset>
    <legend>Topo信息</legend>
    <form:form id="inputFormTopo" modelAttribute="hostLinks" action="${ctx}/inventory/hostInventory/addLink" method="post" class="form-horizontal">
        <form:hidden path="fromHostid"/>
        <form:hidden path="fromHostname"/>
        <form:hidden path="fromHostalias"/>
        <form:hidden path="fromHostType"/>
        <table>
            <tr>
                <td>
                    <div class="control-group"><label>本机连接标识：</label>
                        <form:input path="fromHostlinkid" htmlEscape="false"  class="input-small"/>
                    </div>
                </td>
                <td>
                    <div class="control-group"><label>本机连接属性（端口等）：</label>
                        <form:input path="fromHostlinkattr" htmlEscape="false"  class="input-small"/>
                    </div>
                </td>
                <td>
                    <div class="control-group">
                        <label>关联主机：</label>
                            <sys:treeselect id="host" name="toHostid" value="" labelName="toHostname" labelValue=""
                                            title="主机" url="/inventory/zlmtCabinet/treeData?type=2" cssClass="input-small" allowClear="true" notAllowSelectParent="false"/>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="control-group"><label>关联主机连接标识：</label>
                        <form:input path="toHostlinkid" htmlEscape="false"  class="input-small"/>
                    </div>
                </td>
                <td>
                    <div class="control-group"><label>关联主机连接属性（端口等）：</label>
                        <form:input path="toHostlinkattr" htmlEscape="false"  class="input-small"/>
                    </div>
                </td>
                <td>
                    <div class="control-group"><label>连接备注：</label>
                        <form:input path="linkAttr" htmlEscape="false"  class="input-small"/>
                    </div>
                </td>
                <td  align="right">
                    <input id="btnSubmitLinks" class="btn btn-primary" type="submit" value="添加"/>
                </td>
            </tr>
        </table>
    </form:form>
    <table  id="contentTable1" class="table table-striped table-bordered table-condensed">
        <thead>
        <th>from主机名</th>
        <th>from主机别名</th>
        <th>from主机连接标识</th>
        <th>from主机连接属性</th>
        <th>to主机名</th>
        <th>to主机别名</th>
        <th>to主机连接标识</th>
        <th>to主机连接属性</th>
        <th>连接备注</th>
        <th>操作</th>
        </thead>
        <tbody>
        <c:forEach items="${linkList}" var="link">
            <tr>
                <td>${link.fromHostname}</td>
                <td>${link.fromHostalias}</td>
                <td>${link.fromHostlinkid}</td>
                <td>${link.fromHostlinkattr}</td>
                <td>${link.toHostname}</td>
                <td>${link.toHostalias}</td>
                <td>${link.toHostlinkid}</td>
                <td>${link.toHostlinkattr}</td>
                <td>${link.linkAttr}</td>
                <td>
                    <a href="${ctx}/inventory/hostInventory/deleteLink?hostId=${link.fromHostid}&id=${link.id}" onclick="return confirmx('确认要删除该连接吗？', this.href)">删除</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</fieldset>
        <fieldset>
            <legend>干系人信息</legend>
            <form:form id="inputFormUser" modelAttribute="zlmtResourceUser" action="${ctx}/inventory/hostInventory/addResourceUser" method="post" class="form-horizontal">
            <form:hidden path="hostid"/>
            <table>
                <tr>
                    <td>
                        <div class="control-group"><label>关系类型：</label>
                            <form:select path="relationType" class="input-small">
                                <form:options items="${fns:getDictList('resouce_user_relation')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                            </form:select>
                        </div>
                    </td>
                    <td>
                        <div class="control-group"><label>用户：</label>
                            <sys:treeselect id="user" name="user.id" value="${zlmtResourceUser.user.id}" labelName="user.name" labelValue="${zlmtResourceUser.user.name}"
                                            title="用户" url="/sys/office/treeData?type=3" cssClass="input-small" allowClear="true" notAllowSelectParent="true"/>
                        </div>
                    </td>
                    <td>
                        <input id="btnSubmitAccessory" class="btn btn-primary" type="submit" value="添加"/>
                    </td>
                </tr>
            </table>
            </form:form>
            <table  id="contentTable2" class="table table-striped table-bordered table-condensed">
                <thead>
                <th>干系类型</th>
                <th>姓名</th>
                <th>开始时间</th>
                <th>操作</th>
                </thead>
                <tbody>
                <c:forEach items="${userList}" var="user">
                    <tr>
                        <td>${fns:getDictLabel(user.relationType, "resouce_user_relation", "未知")}</td>
                        <td>${user.user.name}</td>
                        <td><fmt:formatDate value="${user.fromTime}" pattern="yyyy-MM-dd"/></td>
                        <td><a href="${ctx}/inventory/hostInventory/deleteResourceUser?hostid=${user.hostid}&id=${user.id}" onclick="return confirmx('确认要删除该配件吗？', this.href)">删除</a></td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </fieldset>
        <fieldset>
            <legend>维修记录</legend>
            <table  id="contentTable3" class="table table-striped table-bordered table-condensed">
                <thead>
                <th>姓名</th>
                <th>相关配件</th>
                <th>开始时间</th>
                <th>结束时间</th>
                <th>原因</th>
                <th>过程</th>
                <th>结果</th>
                </thead>
                <tbody>
                <c:forEach items="${maintenanceRecordList}" var="maintenanceRecord">
                    <tr>
                        <td>${maintenanceRecord.user.name}</td>
                        <td>${maintenanceRecord.accessoryName}</td>
                        <td><fmt:formatDate value="${maintenanceRecord.fromTime}" pattern="yyyy-MM-dd hh:mm"/></td>
                        <td><fmt:formatDate value="${maintenanceRecord.thruTime}" pattern="yyyy-MM-dd hh:mm"/></td>
                        <td>${maintenanceRecord.maintenanceReason}</td>
                        <td>${maintenanceRecord.maintenanceOperation}</td>
                        <td>${maintenanceRecord.maintenanceResult}</td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </fieldset>

</body>
</html>